package com.sdy.controller;

import com.sdy.entity.User;
import com.sdy.util.R;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * @program: ssm-sm
 * @author: sdy
 * @create: 2022-12-08 10:32
 **/
@RestController
@RequestMapping("/test")
public class TestController {
    @PostMapping("/post1")
    public R t1(User user){
        return R.ok(user);
    }

    @PostMapping("/post2")
    public R t2(User user, MultipartFile tx){
        user.setTxFileName(tx.getOriginalFilename());
        return R.ok(user);
    }

    @PostMapping("/post3")
    public R t3(@RequestBody User user){
        System.out.println(user);
        return R.ok(user);
    }

    @PostMapping("/post4")
    public R t4(@RequestBody List<String> list){
        System.out.println(list);
        return R.ok(list);
    }

    @PostMapping("/restful{sid}")
    public R t4(int sid){
        return R.ok(sid);
    }

    @RequestMapping("/header1")
    public R t5(@RequestHeader String hd,@RequestBody User user){
        return R.ok(hd+user);
    }
}
